import axios from "axios";
import nprogress from "nprogress";
let axiosIns = axios.create({
    baseURL:"http://localhost:3000",
    timeout:2000
})
// 添加请求拦截器
axiosIns.interceptors.request.use(function (config) {
    // 加载进度条
    nprogress.start()
    return config;
}, function (error) {
    return Promise.reject(error);
});

// 添加响应拦截器
axiosIns.interceptors.response.use(function (response) {
    //请求成功后 done 结束 关闭进度条
    nprogress.done()
    return response.data;
}, function (error) {
    nprogress.done()
    return Promise.reject(error);
});

export default axiosIns